
package controller
{
    import model.ElfinProxy;

    import mx.core.FlexGlobals;

    import org.kolonitsky.alexey.debug.DebugWrapper;

    import org.puremvc.as3.interfaces.INotification;

    import org.puremvc.as3.patterns.command.SimpleCommand;

    /**
     * @author: Alexey Kolonitsky <alexey@kolonitsky.org>
     * @date: 2/12/12 - 3:37 PM
     */
    public class ConnectionEstablishedCommand extends SimpleCommand
    {
        override public function execute(notification:INotification):void
        {
            super.execute(notification);
            DebugWrapper.trace("INFO: CMD > ConnectionEstablishedCommand");

            // after success connection to server prepare model and view
            var elfinProxy:ElfinProxy = facade.retrieveProxy(ElfinProxy.NAME) as ElfinProxy;
            sendNotification(AppFacade.PREPARE_MODEL, elfinProxy.config);

            var app:Elfin = FlexGlobals.topLevelApplication as Elfin;
            sendNotification(AppFacade.PREPARE_VIEW, app);

            // Check user authorization
            sendNotification(AppFacade.USER_AUTHORIZATION);
        }
    }
}
